import { GuildCopyEntrancePanelBase } from "./GuildCopyEntrancePanelBase";
import { ObjCreate } from "../../../common/ObjCreate";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { GSprite } from "../../../../../../com/mui/controls/GSprite";
import { CopyConfig } from "../../../../resource/CopyConfig";
import { GScrollPane } from "../../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../../fl/controls/ScrollPolicy";
import { Language } from "../../../../../../extend/language/Language";
import { Cache } from "../../../../cache/Cache";
import { HTMLUtil } from "../../../../../../com/gengine/utils/HTMLUtil";
import { RobCityStep } from "../../../robCity/RobCityStep";
import { Global } from "../../../../../../com/gengine/global/Global";
import { ECopyType } from "../../../../../../Message/Public/ECopyType";
import { HighlightManager } from "../../../../manager/HighlightManager";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../../com/mui/controls/GButton";
//class GuildRobCityEntrancePanel
    
    export  class GuildRobCityEntrancePanel extends GuildCopyEntrancePanelBase
    {
        constructor()
        {
            super();
            ObjCreate.createLoadedBitmap("text_shengtianrukou.png", 23, 66, this);
            this._numLabel = ObjCreate.createGTextField("", 122, 68, 200, 20, this);
            var loc1=new GTextFormat(FontUtil.songtiName, 12, GlobalStyle.color1Uint, null, null, null, null, null, null, null, null, null, 3);
            var loc2=new GSprite();
            this._descText = ObjCreate.createGTextField("", 0, 0, 290, 230, loc2, loc1);
            this._descText.wordWrap = true;
            this._descText.multiline = true;
            this._descText.mouseWheelEnabled = false;
            this._descText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._descText.htmlText = CopyConfig.instance.getGuildCopyDesc(8);
            var loc3=new GScrollPane();
            loc3.x = 28;
            loc3.y = 100;
            loc3.width = 300;
            loc3.height = 245;
            loc3.styleName = "GScrollPane";
            loc3.verticalScrollPolicy = ScrollPolicy.AUTO;
            loc3.horizontalScrollPolicy = ScrollPolicy.OFF;
            loc3.source = loc2;
            loc3.scrollDrag = false;
            loc3.setScrollBarSize(19);
            addChild(loc3);
            loc3.update();
            this._optBtn = ObjCreate.createGButton(Language.getString(60407), 135, 355, 72, 26, this);
            this._optBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOptButtonClick);
            return;
        }

        public /* override */ updateStatus(): void
        {
            var loc1=Cache.instance.robCity.robCityCopyOneInfo;
            if (!loc1) 
            {
                return;
            }
            this._numLabel.htmlText = HTMLUtil.addColor(Language.getString(60952) + " （" + loc1.weekCount + "/1）", "#FFFF00");
            var loc2=false;
            if (!(Cache.instance.robCity.getRobCityStep() == RobCityStep.StepOne) && !Global.isDebugModle) 
            {
                this._optBtn.label = Language.getString(60407);
                this._optBtn.enabled = true;
            }
            else if (loc1.weekCount != 0) 
            {
                if (loc1.hasOpen) 
                {
                    this._optBtn.label = Language.getString(60408);
                    if (Cache.instance.copy.isInCopyType(ECopyType._ECopyRobCityOne)) 
                    {
                        this._optBtn.enabled = false;
                    }
                    else 
                    {
                        this._optBtn.enabled = true;
                        loc2 = true;
                    }
                }
                else 
                {
                    this._optBtn.label = Language.getString(60407);
                    this._optBtn.enabled = true;
                }
            }
            else 
            {
                this._optBtn.label = Language.getString(60407);
                this._optBtn.enabled = true;
            }
            HighlightManager.instance.glowEffectButton(this._optBtn, loc2);
            return;
        }

        /* internal  */onOptButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._optBtn.label;
            switch (loc1) 
            {
                case Language.getString(60407):
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_doOpenCopyOne));
                    break;
                }
                case Language.getString(60408):
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_doEnterCopy, ECopyType._ECopyRobCityOne));
                    break;
                }
            }
            return;
        }

        /* internal */ /* var */_numLabel: GTextFiled;

        /* internal */ /* var */_descText: GTextFiled;

        /* internal */ /* var */_optBtn: GButton;
    }
